﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Nollie.Storage.Database;

namespace Nollie.CacheTypes.Database
{
	public class DbCache : ICache, IDbCache
	{
		private Dictionary<string, Partition> _partitions = new Dictionary<string, Partition>();
		private IDatabaseStorage _cacheStorage;
		private ReaderWriterLockSlim _locker = new ReaderWriterLockSlim();

		public DbCache(CacheConfiguration configuration)
		{
			_cacheStorage = new SqlServerStorage(configuration);
		}

		public IPartition GetDbPartition(string partitionName)
		{
			return new Partition(this, _cacheStorage, partitionName, PartitionTypes.Db, 0);
		}
		public void ClearAllPartitions()
		{
			_cacheStorage.ClearAllPartitions();
		}
		public void RemoveByTag(string tag)
		{
			_cacheStorage.RemoveByTag(tag);
		}
	}
}
